<template>
<div>
  <h1>欢迎来到{{name}}的商店,修改页面</h1>
  <table>
    <tr>
      <td>名称</td>
      <td>价格</td>
      <td>展示</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in list">
      <td>{{i.name}}</td>
      <td>{{i.price}}</td>
      <td>
        <img :src="'http://127.0.0.1:8000'+i.pic" alt="" width="200px">
      </td>
      <td>
        <button @click="delete1(i.id)">删除</button>
      </td>
    </tr>
  </table>
  <button v-for="i in num" @click="show_goods(i)">{{i}}</button>


</div>
</template>

<script>
export default {
  name: "ssupdet",
  data() {
    return {
      name: localStorage.getItem('name'),
      user: localStorage.getItem('userid'),
      list: []
    }
  },
  methods:{
    show_goods(i){
      this.$axios.get('users/ShangDian_API/?cpage='+i+'&user='+this.user)
        .then(i=>{
          this.list = i.data.list
          this.num = i.data.num
        })
    },
    delete1(id){
      this.$axios.delete('users/ShangDian_API/?id='+id)
      .then(i=>{
        if (i.data.code == 200){
          alert('删除成功')
          this.show_goods(1)
        }
        else {
          alert("删除失败")
        }
      })
    }

  },
  mounted() {
    this.show_goods(1)
  }
}
</script>

<style scoped>

</style>
